<nz-breadcrumb class="breadcrumb">
  <nz-breadcrumb-item>
    <a routerLink="/Home">首页</a>
  </nz-breadcrumb-item>
  <nz-breadcrumb-item>住户信息列表</nz-breadcrumb-item>
</nz-breadcrumb>
<form nz-form class="search-form" [formGroup]="searchForm" (keydown.enter)="$event.preventDefault();onSearch()" nzLayout="inline">
  <nz-form-item>
    <nz-form-label nzFor="name">住户姓名</nz-form-label>
    <nz-form-control>
      <input nz-input formControlName="name" placeholder="请输入住户姓名" />
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label nzFor="phone">联系电话</nz-form-label>
    <nz-form-control>
      <input nz-input formControlName="phone" placeholder="请输入联系电话" />
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label nzFor="buildingName">楼栋名称</nz-form-label>
    <nz-form-control>
      <nz-input-group nzSearch [nzAddOnAfter]="buildingNameSuffixIconButton">
        <input nz-input formControlName="buildingName" placeholder="请选择楼栋名称" readonly />
      </nz-input-group>
      <ng-template #buildingNameSuffixIconButton>
        <button nz-button nzType="primary" nzSearch (click)="findBuilding()"><nz-icon nzType="search" /></button>
      </ng-template>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label nzFor="roomNumber">单元房号</nz-form-label>
    <nz-form-control>
      <nz-input-group nzSearch [nzAddOnAfter]="roomNumberSuffixIconButton">
        <input nz-input formControlName="roomNumber" placeholder="请选择单元房号" readonly />
      </nz-input-group>
      <ng-template #roomNumberSuffixIconButton>
        <button nz-button nzType="primary" nzSearch (click)="findRoom()"><nz-icon nzType="search" /></button>
      </ng-template>
    </nz-form-control>
  </nz-form-item>
  <nz-form-item>
    <nz-form-label nzFor="type">住户类型</nz-form-label>
    <nz-form-control>
      <nz-select formControlName="type" class="custom-select-width">
        <nz-option nzLabel="业主" [nzValue]="10"></nz-option>
        <nz-option nzLabel="成员" [nzValue]="20"></nz-option>
        <nz-option nzLabel="租户" [nzValue]="30"></nz-option>
      </nz-select>
    </nz-form-control>
  </nz-form-item>
  <button nz-button type="button" nzType="primary" [nzLoading]="searchLoading" (click)="onSearch()">查询</button>
  <button nz-button type="button" class="margin-button" (click)="onReset()">重置</button>
  <button nz-button type="button" class="margin-button" nzType="primary" (click)="onAdd()">新增</button>
  <button nz-button type="button" class="margin-button" nzType="primary" [nzLoading]="searchLoading" (click)="onExport()">导出</button>
</form>
<nz-table #basicTable [nzData]="listOfData" [nzTotal]="total" [nzLoading]="searchLoading" nzSize="small">
  <thead>
    <tr>
      <th>住户姓名</th>
      <th>联系电话</th>
      <th>电子邮箱</th>
      <th>楼栋名称</th>
      <th>单元房号</th>
      <th>入驻日期</th>
      <th>搬出日期</th>
      <th>住户类型</th>
      <th nzWidth="250px">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of basicTable.data">
      <td>{{data.name}}</td>
      <td>{{data.phone}}</td>
      <td>{{data.email}}</td>
      <td>{{data.buildingName}}</td>
      <td>{{data.roomNumber}}</td>
      <td>{{data.moveInDate}}</td>
      <td>{{data.moveOutDate}}</td>
      <td>
        <ng-container *ngIf="data.type === 10">业主</ng-container>
        <ng-container *ngIf="data.type === 20">成员</ng-container>
        <ng-container *ngIf="data.type === 30">租户</ng-container>
      </td>
      <td>
        <button nz-button type="button" nzType="primary" (click)="editRow(data.id)">编辑</button>
        <button nz-button type="button" nzDanger class="margin-button" (click)="delRow(data.id)">删除</button>
        <button nz-button type="button" class="margin-button" (click)="detailRow(data)">详情</button>
      </td>
    </tr>
  </tbody>
</nz-table>
<building-selector (buildingSelectedEvent)="handleBuildingSelectedEvent($event)"></building-selector>
<room-selector (roomSelectedEvent)="handleRoomSelectedEvent($event)"></room-selector>
<resident-add (addedEvent)="onAdded($event)"></resident-add>
<resident-view></resident-view>
